import { defineStore } from "pinia";
import { ref } from "vue";
import type { TopCate } from "@/types/cate";
import { fetchCateListAPI } from "@/api/cateApi";

const useCateStore = defineStore("cateStore", () => {

    /*分类数据*/
    const cateList = ref<TopCate[]>([]);

    /*获取商品分类数据的请求函数*/
    const fetchCateList = async (): Promise<void> => {
        const { result }: { result: TopCate[] } = await fetchCateListAPI();
        cateList.value = result;
    };

    return {
        cateList,
        fetchCateList,
    };
});


export default useCateStore;
